
//项目视图
function displayp(divid)
{	
	var DivId="#pview"+divid;
	$(DivId).toggle();
}
function viewp(sortid){
	var DivId=new Array();
	DivId[1]="#pview1";
	DivId[2]="#pview2";
	DivId[3]="#pview3";
	//alert();
	$(DivId[1]).hide();
	$(DivId[2]).hide();
	$(DivId[3]).hide();
	
	$(DivId[parseInt(sortid)]).show();

	addproject_xx(sortid);
}
//更新分组显示
function displayg(Id){
	$("#updateg_c"+Id).toggle();
}
//显示class
function displayc(id){
	$("."+id).toggle();
}
//增加用户
function group_adduser(groupid,tag,id){
	$("."+id).toggle();
	var group="<input type=\"hidden\" name='groupid' value='"+groupid+"' />";
	$(".admin_add_groupid").html(group);
	var fid="<input type='hidden' name='fid' value='"+tag+"' />";
	$(".admin_add_fid").html(fid);
}

//导航滑动
function index_nav(item){
	var thetop="-640px";
	var thec1="#93d408";
	var thec2="#43b856";
	if(item==2){
		var thetop="-1340px";
		var thec1="#17ceed";
		var thec2="#26aeec";
	}
	else if(item==3){
		location='admin.project.grade.php';
		return 0;
	}
	else if(item==4){
		var thetop="-2040px";
		var thec1="#ef1ead";
		var thec2="#ba1184";
	}
	$(".admin_group").animate({top:thetop},500);
	$(".admin_project").animate({top:thetop},500);
	$(".admin_system").animate({top:thetop},500);
	$(".admin_circle_border").css("background-color",thec1);
	$(".admin_circle_border").css("border","solid 8px "+thec2);
	$(".admin_circle").css("background-color",thec2);	
}




var XMLHttpRequestObject=false;
if(window.XMLHttpRequest)
{
	XMLHttpRequestObject=new XMLHttpRequest();
}
else if(window.ActiveXObject)
{
	XMLHttpRequestObject=new ActiveXObject("Microsoft.XMLHTTP");
}

//通过ajax获取信息，地址为dataSource，获取内容在divID中，传输数据位data
function getmessage(dataSource,divID,dataname,data)
{
	if(XMLHttpRequestObject)
	{

		var obj=document.getElementById(divID);
		XMLHttpRequestObject.open("POST",dataSource,true);
		XMLHttpRequestObject.setRequestHeader("Content-Type","application/x-www-form-urlencoded");  
		XMLHttpRequestObject.send(dataname+"="+data);
		XMLHttpRequestObject.onreadystatechange=function ()
		{

			if(XMLHttpRequestObject.readyState==4&&XMLHttpRequestObject.status==200)
			{

				obj.innerHTML=XMLHttpRequestObject.responseText;
			}
		}
		
	}
}

function domessage(dataSource,dataname,data)
{
	
	if(XMLHttpRequestObject)
	{
		XMLHttpRequestObject.open("POST",dataSource,true);
		XMLHttpRequestObject.setRequestHeader("Content-Type","application/x-www-form-urlencoded");  
		XMLHttpRequestObject.send(dataname+"="+data);
		XMLHttpRequestObject.onreadystatechange=function ()
		{

			if(XMLHttpRequestObject.readyState==4&&XMLHttpRequestObject.status==200)
			{
				var check=0;
				check=XMLHttpRequestObject.responseText;
				//alert(check);
				if(check=="OK"){
					alert("操作成功");
					window.location.reload(); 
				}
				else{
					alert("操作失败");
				}

			}
		}
		
	}

}

function getproject_xx(sortid){
	getmessage('index.php','admin_index_project_update','getp',sortid);
}
function addproject_xx(sortid){
	getmessage('index.php','admin_index_project_update','addp',sortid);
}
function deletep(sortid){
	domessage('index.php','delp',sortid);
}
function getgroup_xx(groupid){
	getmessage('index.php','admin_index_group_update','getg',groupid);
}
function system_open(){
	//alert("系统开启");
	if(confirm("确定开启系统?这样会删除所有现存测评数据。")){
		domessage('admin.system.operation.php','sysgn',1);
	}
}
function system_closs(){
	//alert("系统关闭");
	if(confirm("确定关闭系统?")){
		domessage('admin.system.operation.php','sysgn',2);
	}
}
function system_reset(){
	//alert("系统重置");
	if(confirm("确定重置系统?这样会删除所有系统数据。")){
		domessage('admin.system.operation.php','sysgn',3);
	}
}

//设置滑动框样式
/*
$(document).ready(function() {
    var nicesx = $(".admin_project_view").niceScroll({
      touchbehavior:false,
      cursorcolor:"#17ceed",
      cursoropacitymax:0.5,
      cursorwidth:8
  	});
    
  });
  */